import numpy as np
import os

def pr():
    for num in range(3,10):
        
        total_nums = 1000
        ture_nums = num * 100
        false_nums = total_nums - ture_nums
        lines = []

        line = ", "
        for tn in range(0,false_nums,10):
            fp = false_nums - tn
            line += "TN:{}/FP:{}, ".format(tn, fp)
        lines.append(line)

        for tp in range(0,ture_nums,10):
            fn = ture_nums - tp
            line = "TP:{}/FN:{}, ".format(tp, fn)

            for tn in range(0,false_nums,10):
                fp = false_nums - tn

                precision = tp / (tp + fp)
                recall = tp / (tp + fn)

                line += "{}/{}, ".format(str(precision)[:6], str(recall)[:6])

                # print("tp:{}, fp:{}, fn:{}, tn:{}, p:{}, r:{}".format(tp, fp, fn, tn, precision, recall)) 
            lines.append(line)
        
        with open("{}.txt".format(num), "w") as wf:
            for line in lines:
                wf.write(line+"\n")


def pr2():
    # 表示总目标1000个，正确检测300个，误检测0～1500个时
    total_gt = 1000
    max_ture_nums = total_gt
    max_false_nums = 1500
    lines = []

    line = ", "
    for false_num in range(0,max_false_nums,10):
        line += "{}, ".format(false_num)
    lines.append(line)

    for ture_num in range(0,max_ture_nums,10):
        line = "{}, ".format(ture_num)

        for false_num in range(0,max_false_nums,10):

            

            p = false_num / total_gt
            o = ture_num / total_gt

            line += "P:{}/O:{}, ".format(str(p)[:6], str(o)[:6])

            # print("tp:{}, fp:{}, fn:{}, tn:{}, p:{}, r:{}".format(tp, fp, fn, tn, precision, recall)) 
        lines.append(line)
    
    with open("pr2.txt", "w") as wf:
        for line in lines:
            wf.write(line+"\n")

if __name__ == "__main__":
    pr2()